<?php
/*
 * Creative Bulletin Board Generation 3
 * Version 1.0 Beta 1
 +------------------------------------
 * User Application, Registration Module (Frontend)
 * Started: 27 September 2009 9:12 AM
 * Script version: 1.0
 +------------------------------------
 */

class module implements module_interface{
	public function returninitvars(){
		global $lang;
		$this->info["page_title"] = $lang->getByKey("user.register");
		$this->info["page_description"] = "";
		$this->info["module_version"] = "1.0";
		return $this->info;
	}

	public function construct(){
		global $db, $view, $lang;
		$this->run = ($db->conf_value("can_register") == "1" ? true : false);
		if(!$this->run){
			$view->writeIn($view->inlineError($lang->getByKey("user.register.disabled")));
			$this->custom_error = true; # Turn off module error handler
		}
	}
	
	public function run(){
		global $view, $config, $db, $main, $lang;
		if(isset($_SESSION["cf_username"], $_SESSION["cf_controller"])){
			$view->writeIn($view->inlineWarning($lang->getByKey("user.register.notguest")));
		}
		else{
			// So we first... Uhh... Steps.
			switch((isset($_GET["step"]) ? $_GET["step"] : 1)){
				case 1:
					$this->output = $view->showTemplate("register_step1"); # Terms and Conditions / Rules
				break;
				case 2:
					$this->output = $view->showTemplate("register_step2"); # Form
				break;
				case 3:
					// Not implemented. MKAccount here.
				break;
			}
		}
	}

	public function destruct(){}
}
